package com.saku.uiprojecttest.activities;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;

import com.saku.uiprojecttest.R;
import com.saku.uiprojecttest.bean.Test;

import java.util.ArrayList;
import java.util.List;

/**
 * User: Missa
 * Date: 2016-12-14
 * Time: 11:40
 * Description:
 */
public class TestAcitivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test);

        Intent intent = getIntent();
        if (intent != null) {
            Log.d("lm", "TestAcitivity:　action: " + intent.getAction());
            Log.d("lm", "TestAcitivity:　getData: " + intent.getData());
            Log.d("lm", "TestAcitivity:　getQueryParameterNames: " + intent.getData().getQueryParameterNames());
            Log.d("lm", "TestAcitivity:　getPath: " + intent.getData().getPath());
            Log.d("lm", "TestAcitivity:　goodsId: " + intent.getData().getQueryParameter("goodsId"));
        }

        //,'熊出没快跑熊出没之熊大快跑','熊出没之熊大快跑','熊出没之熊大快跑','熊出没之熊大快跑','视频','放开那三国','电子书','酒店','单机','小说','斗地主','优酷','网游','WIFI万能钥匙真好用','播放器','捕鱼达人2','机票','游戏','熊出没之熊大快跑'
        String[] strResponse1 = {"熊大快跑","捕2","大大咧咧","蓝光光"};
        String[] strResponse2 = {"播放器","游戏","视频"};
        String[] strResponse3 = {"放开那三国","电子书","酒店","单机"};

        List<Test> testList = new ArrayList<>();
        Test t1 = new Test();
        t1.tags = strResponse1;
        testList.add(t1);

        Test t2 = new Test();
        t2.tags = strResponse2;
        testList.add(t2);

        Test t3 = new Test();
        t3.tags = strResponse3;
        testList.add(t3);

        Test t4 = new Test();
        t4.tags = strResponse3;
        testList.add(t4);

        Test t5 = new Test();
        t5.tags = strResponse3;
        testList.add(t5);

        Test t6 = new Test();
        t6.tags = strResponse3;
        testList.add(t6);

        RecyclerView recyclerView = (RecyclerView) findViewById(R.id.rv);
        recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));

        recyclerView.setAdapter(new TestRecyclerAdapter(this, testList));

//        String strResponse = "['熊大快跑','器','捕2','机','游戏','熊出没快跑熊出没之熊大快跑','熊出没之熊大快跑','熊出没之熊大快跑','熊出没之熊大快跑','视频','放开那三国','电子书','酒店','单机','小说','斗地主','优酷','网游','WIFI万能钥匙真好用','播放器','捕鱼达人2','机票','游戏','熊出没之熊大快跑',,'熊出没之熊大快跑','熊出没之熊大快跑','视频','放开那三国','电子书','酒店','单机','小说','斗地主','优酷','网游','WIFI万能钥匙真好用','播放器','捕鱼达人2','机票','游戏',,'熊出没之熊大快跑','熊出没之熊大快跑','视频','放开那三国','电子书','酒店','单机','小说','斗地主','优酷','网游','WIFI万能钥匙真好用','播放器','捕鱼达人2','机票','游戏','熊出没之熊大快跑','熊出没之熊大快跑','视频','放开那三国','电子书','酒店','单机','小说','斗地主','优酷','网游','WIFI万能钥匙真好用','播放器','捕鱼达人2','机票','游戏']";
//
//
//        TagLayout tll = (TagLayout) findViewById(R.id.taglayout);
//        try {
//            JSONArray ja = new JSONArray(strResponse);
//            Random r = new Random(255);
//            for (int i = 0; i < ja.length(); i++) {
//                Log.d("lm", "TestAcitivity: i = " + i);
//                TextView tv = new TextView(this);
//                tv.setText((String) ja.opt(i));
//                tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
//                tv.setGravity(Gravity.CENTER);
//                tv.setPadding(10, 10, 10, 10);
//                GradientDrawable drawable = new GradientDrawable();
//                drawable.setShape(GradientDrawable.RECTANGLE);
//                drawable.mutate();
//                drawable.setCornerRadius(10);
//                drawable.setColor(Color.rgb(r.nextInt(), r.nextInt(), r.nextInt()));
//                tv.setBackground(drawable);
//                tll.addView(tv);
//
//            }
//
//        } catch (JSONException e) {
//            e.printStackTrace();
//        }
        Handler h = new Handler();
    }
}
